package cn.letao;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private ImageView image;
    private Button btn;
    private int img[]={R.drawable.b1,R.drawable.b2,R.drawable.b3,R.drawable.b4,R.drawable.b5,};
    private int index = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.text1);
        textView.setTextSize(40);
        textView.setTextColor(Color.BLUE);
        textView.setText(R.string.text_view);

        image = findViewById(R.id.image);
        image.setImageResource(R.drawable.b1);

        btn = findViewById(R.id.btn);
        btn.setText(R.string.btn_name);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                index = (index+1)%img.length;
                image.setImageResource(img[index]);
            }
        });
    }
}
